<?php

class Page_auth
{
	private $CI;
	public function __construct()
	{
		$this->CI =& get_instance();
	}
	// redirects page to specified controller only
	public function secure_page($redirect_to = FALSE)
	{
		if($this->CI->session->userdata('logged_in') === TRUE)
		{
			// if($this->CI->uri->segment(1) !== $this->CI->session->userdata('userType'))
			// {
				// redirect($this->CI->session->userdata('userType'));
			// }
		}else
		{
			$this->CI->disable_browser_cache = TRUE;
			if($redirect_to == FALSE)
			{
				$message = '<div class="alert alert-danger">You\'re session has expired, please login again to continue.</div>';
				$this->CI->_msg('n',$message,'auth/login/');
			}else{
				redirect($redirect_to);
			}
			
		}		
	}
}